package com.tools.starter.swagger.sqlite;

import com.tools.starter.swagger.aop.MockAop;
import com.tools.starter.swagger.rest.MockController;
import com.tools.starter.swagger.runner.SwaggerSqliteCommandLineRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.HandlerMapping;
import springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping;

/**
 * @author com.tools
 * @version 1.0
 * @Description: SQLiteConfiguration
 * <com.tools.starter.swagger.sqlite>
 * @date Created in 2020/9/1 11:50
 **/
@Configuration
@Import({ SwaggerSqliteCommandLineRunner.class, MockAop.class})
@ComponentScan(basePackages = {
    "com.tools"
})
@ConditionalOnWebApplication
public class SQLiteConfiguration {

    @Bean
    public HandlerMapping mockControllerMapping(Environment environment) {
        return new PropertySourcedRequestMappingHandlerMapping(
            environment,
            new MockController());
    }
}
